using System;
using QAssetBundle;
using UnityEngine;
using QFramework;

namespace ProjectSurvival
{
    public partial class Exp : PowerUp
    {
        private Collider2D _collider;


        private void Awake()
        {
            _collider = GetComponent<Collider2D>();
        }

        void Start()
        {
            gameObject.OnTriggerEnter2DEvent((other) =>
            {
                if (other.GetComponent<CollectableArea>())
                {
                    FlyToPlayer = true;
                }
            }).UnRegisterWhenGameObjectDestroyed(gameObject);
        }
        protected override void Execute()
        {
            AudioKit.PlaySound(Exp_wav.Exp);
            Global.Experience.Value++;
            gameObject.DestroySelfGracefully();
        }

        protected override Collider2D Collider => _collider;
    }
}